<template tag="以下文档内容为hycli自动生成">
  <div style="height: 100%">
    <div style="margin:0.8rem;"><h5 style="display:inline">周报</h5><span style="margin-left: 0.5rem; color:#999"> </span>
    </div>
    <hr style="margin-top:0;color:#999"/>
<div class="query">
    
    <el-form :model="form_aabbr" inline >
        <!-- 日期控件个数： 1 -->
        <el-form-item>
            <!--多日期范围控件 -->
            <el-select v-model="form_aabbr.single_date_range_name" filterable placeholder="日期类型" style="width:120px;" class="prepend">
                <el-option
                v-for="item in multiQueryDateRange"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
        </el-select>
            <el-date-picker :shortcuts="shortcuts" style="width: 200px" v-model="form_aabbr.single_date_range_value" type="daterange" start-placeholder="开始日期"
                end-placeholder="结束日期" format="YYYY-MM-DD" value-format="YYYY-MM-DD" />
        </el-form-item>
        <!--用户 下拉控件 -->
        <el-form-item>
            <el-select  v-model="form_aabbr.user_id" style="width: 100px" filterable clearable placeholder="用户">
                <el-option v-for="item in user_idList" :key="item.value" :label="item.name" :value="item.value" />
            </el-select>
        </el-form-item>
        <!-- 控件个数：[{"index":23,"raw":"report_content","name":"report_content","cname":"ReportContent","type":{"raw":"text","name":"text","len":0,"dlen":0},"defValue":"","allowNull":true,"constraints":["l","le","c","q","v","u","rows(12)"],"desc":{"raw":"内容","name":"内容"}}] -->
         <el-form-item>
            <el-input clearable style="width: 180px" v-model="form_aabbr.single_text_value" maxlength="32"
                placeholder="关键字" >
                <template #prepend>
                    <el-select v-model="form_aabbr.single_text_name" placeholder="查询类型" style="width:84px;">
                        <el-option
                        v-for="item in multiQueryText"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                      />
                      </el-select>
                  </template>
            </el-input>
        </el-form-item>

        <span class="ddl">
        </span>
        <el-form-item>
            <el-space wrap>
                <el-button type="primary" icon="Search" @click="onQuery(true)">查询</el-button>
                <el-button :type="$js.page.tagColor(0)"  icon="Plus"  @click="show_cmpnt_aabbv">添加</el-button>
            </el-space>
        </el-form-item>
        

        <!-- xtabs -->
        

    </el-form>
</div>
<div>
   <aabbv ref="cmpnt_aabbv" @onsaved="onQuery"></aabbv>
   <aabbs ref="cmpnt_aabbs" @onsaved="onQuery"></aabbs>
   <aabbt ref="cmpnt_aabbt" @onsaved="onQuery"></aabbt>
   <aabbu ref="cmpnt_aabbu" @onsaved="onQuery"></aabbu>
</div>
<div class="list">
    <el-table :data="dataList_aabbr"
    
    v-loading="conf.loading" stripe  style="width: 100%;height:calc(100vh - 160px)"
         empty-text="无数据">le
<el-table-column width="24px" type="expand">
    <template #default="view">
        <el-row :gutter="24">
            <el-col :span="5" class="text-right" style="min-height:26px">编号:</el-col>
            <el-col :span="7" v-text="view.row.le_wr_id" style="min-height:26px" ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">用户:</el-col>
            <el-col :span="7" v-text="view.row.user_id_label" style="min-height:26px"
              ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">开始日期:</el-col>
            <el-col :span="7" v-text="view.row.le_start_date" style="min-height:26px" ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">结束日期:</el-col>
            <el-col :span="7" v-text="view.row.le_end_date" style="min-height:26px" ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">内容:</el-col>
            <el-col :span="7" v-text="view.row.le_report_content" style="min-height:26px" ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">反馈:</el-col>
            <el-col :span="7" v-text="view.row.le_feedback_content" style="min-height:26px" ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">汇报给:</el-col>
            <el-col :span="7" v-text="view.row.report_to_user_label" style="min-height:26px"
              ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">抄送用户:</el-col>
            <el-col :span="7" v-text="view.row.cc_users_label" style="min-height:26px"
              ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">创建时间:</el-col>
            <el-col :span="7" v-text="view.row.le_create_time" style="min-height:26px" ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">更新时间:</el-col>
            <el-col :span="7" v-text="view.row.le_update_time" style="min-height:26px" ></el-col>
        </el-row>
    </template>
</el-table-column>
        
        	<!--wr_id text -->
        <el-table-column  show-overflow-tooltip    align="center" label="编号" >
            <template #default="scope">
                  <span>{{ scope.row.wr_id||'-' }}</span>
              </template>
        </el-table-column>
        	<!--user_id select -->
        <el-table-column    min-width="60"   prop="user_id" align="center" label="用户">
            <template #default="scope">
                <span 
                    v-text="scope.row.user_id_label"></span>
            </template>
        </el-table-column>
        	<!--start_date date -->
        <el-table-column  show-overflow-tooltip   min-width="80"   align="center" label="开始日期" >
            <template #default="scope">
                  <span>{{ scope.row.start_date||'-' }}</span>
              </template>
        </el-table-column>
        	<!--report_content text -->
        <el-table-column  show-overflow-tooltip    align="center" label="内容" >
            <template #default="scope">
                  <span>{{ scope.row.report_content||'-' }}</span>
              </template>
        </el-table-column>
        	<!--report_to_user multiselect -->
        <el-table-column     prop="report_to_user" align="center" label="汇报给">
            <template #default="scope">
                <span 
                    v-text="scope.row.report_to_user_label"></span>
            </template>
        </el-table-column>

<el-table-column fixed="right" align="center" label="操作" width="168">
    <template #default="scope">
        <div class="opts">
            <el-button   type="text" @click="show_cmpnt_aabbs(scope.row)" >详情 </el-button>
            <el-button   type="text" @click="show_cmpnt_aabbt(scope.row)" >修改 </el-button>
            <el-button   type="text" @click="show_cmpnt_aabbu(scope.row)" >删除 </el-button>
        </div>
    </template>
</el-table-column>
    </el-table>
    <el-pagination :currentPage="form_aabbr.pi" :page-size="form_aabbr.ps"
        style="position: absolute; right: 30px;bottom:6px;" :page-sizes="[10,15,20,30, 50, 100]" :background="false" small
        layout="total,sizes,prev, pager, next, jumper" :total="total_aabbr" @size-change="handleSizeChange"
        @current-change="handleCurrentChange" />
</div>
  </div>
</template>
<script>
// 添加
import aabbv from "@/views/ws/weekly/weekly_report.add"
// 详情
import aabbs from "@/views/ws/weekly/weekly_report.view"
// 修改
import aabbt from "@/views/ws/weekly/weekly_report.edit"
// 删除
import aabbu from "@/views/ws/weekly/weekly_report.cnfrm"



export default {
components: {
    aabbv,
    aabbs,
    aabbt,
    aabbu,
},
data() {
  return {
    shortcuts: this.$js.page.latestDays(),
    cmpnt_funcs:{},
    conf: {
      loading: false,
      progressColor: this.$theia.env.conf.progress || []
    },
    ganttIdx: -1,
        form_aabbr: {
            pi: 1,
            ps: 15,
            disabled:false,
            single_date_range_name:"",
            single_date_range_value:[],
            single_text_name:"",
            single_text_value:"",
            user_id:"",
            start_date:"",
            report_content:"",
            },
            user_idList:[],
            report_to_userExts:[],
            report_to_userList:[],
            cc_usersExts:[],
            cc_usersList:[],
            dataList_aabbr:[],
            multiQueryDateRange:[{label:"开始日期",value:"start_date"},],
            multiQueryText:[{label:"内容",value:"report_content"},],
            total_aabbr:0,
            note_dataList:[],
};
  },
mounted() {
  this.loadEnums_aabbr()
  this.form_aabbr.single_date_range_name = (this.multiQueryDateRange[0]||{}).value
  this.form_aabbr.single_text_name = (this.multiQueryText[0]||{}).value
  this.cmpnt_funcs["aabbv"] = this.show_cmpnt_aabbv
  this.cmpnt_funcs["aabbs"] = this.show_cmpnt_aabbs
  this.cmpnt_funcs["aabbt"] = this.show_cmpnt_aabbt
  this.cmpnt_funcs["aabbu"] = this.show_cmpnt_aabbu

  this.form_aabbr = Object.assign(this.form_aabbr,this.$route.params)
  this.queryData_aabbr ()
    },
methods: {
  ganttChange(id) {
      this.ganttIdx = id
    },

queryData_aabbr(mform = {},nform={}){
    //构建查询参数
    let queryForm = Object.assign({},this.form_aabbr)
    queryForm = Object.assign(queryForm,nform||{})
    
    //处理多个日期选择
    queryForm[this.form_aabbr.single_date_range_name] = this.form_aabbr.single_date_range_value
    queryForm[this.form_aabbr.single_text_name] = this.form_aabbr.single_text_value
   
    //处理日期范围选择
      queryForm.start_start_date = null
      queryForm.end_start_date = null
    if(queryForm.start_date && queryForm.start_date.length > 1){
      queryForm.start_start_date = queryForm.start_date[0]
      queryForm.end_start_date = queryForm.start_date[1]
    }

    queryForm[this.form_aabbr.single_date_range_name] = null
    queryForm.single_date_range_value = null
    queryForm.single_date_range_name = null

    queryForm.single_text_value = null
    queryForm.single_text_name = null
 
    //处理关联表weekly_report weekly_report 
   
    //发送查询请求
    let that = this
    that.conf.loading = true
    //构建统计查询
  //数据查询
  this.$theia.http.get("/ws/weekly/report/query",queryForm).then(res=>{
      if((res.items||[]).length < (queryForm.ps||10)){
        that.form_aabbr.disabled = true
      }
      that.conf.loading = false
      that.dataList_aabbr = res.items||[]
      that.total_aabbr = res.count
      that.resetItemData_aabbr(that,that.dataList_aabbr)
    });
  },

  resetItemData_aabbr(that,lst){
    lst.forEach(item => {
      item.__raw = Object.assign({}, item)
    item.user_id_label = that.$theia.enum.getName("user_account",item.user_id)
    item.report_to_user_label = that.$theia.enum.getName("user_account",item.report_to_user)
    item.cc_users_label = that.$theia.enum.getName("user_account",item.cc_users)
    item.wr_id_progress = item.wr_id
    item.user_id_progress = item.user_id
    item.start_date_progress = item.start_date
    item.end_date_progress = item.end_date
    item.report_content_progress = item.report_content
    item.feedback_content_progress = item.feedback_content
    item.report_to_user_progress = item.report_to_user
    item.cc_users_progress = item.cc_users
    item.create_time_progress = item.create_time
    item.update_time_progress = item.update_time
    item.le_wr_id = item.wr_id
    item.le_user_id = item.user_id
    item.le_start_date = that.$theia.str.dateFormat(item.start_date,'yyyy/MM/dd')
    item.le_end_date = that.$theia.str.dateFormat(item.end_date,'yyyy/MM/dd')
    item.le_report_content = item.report_content
    item.le_feedback_content = item.feedback_content
    item.le_report_to_user = item.report_to_user
    item.le_cc_users = item.cc_users
    item.le_create_time = item.create_time
    item.le_update_time = item.update_time
    item.start_date = that.$theia.str.dateFormat(item.start_date,'yyyy/MM/dd')
    if(item.children){
      that.resetItemData_aabbr(that,item.children)
    }
  });
  },
    loadEnums_aabbr(){
        //用户
        this.user_idList = this.$theia.enum.get("user_account","","" ,false,"")
        //用户
        this.user_idList = this.$theia.enum.get("user_account","","" ,false,"")
        //汇报给
        this.report_to_userList = this.$theia.enum.get("user_account","","" ,false,"")
    },

  handleSizeChange(ps){
    this.form_aabbr.ps = ps
    this.onQuery(true)
  },
  handleCurrentChange(pi){
    this.form_aabbr.pi = pi
    this.onQuery()
  },
  onQuery(refresh){
    if(refresh){
      this.form_aabbr.pi = 1
    }
    this.queryData_aabbr ()
  },
show_cmpnt(cmd,row){
  if(this.cmpnt_funcs[cmd]){
    this.cmpnt_funcs[cmd](row)
  }
},
  //详情
  show_cmpnt_aabbs(fm = {}){
    let query = {} 
    query.wr_id = fm.wr_id|| fm.le_wr_id 
    query.user_id = fm.user_id|| fm.le_user_id 
    query.start_date = fm.start_date|| fm.le_start_date 
    query.end_date = fm.end_date|| fm.le_end_date 
    query.report_content = fm.report_content|| fm.le_report_content 
    query.feedback_content = fm.feedback_content|| fm.le_feedback_content 
    query.report_to_user = fm.report_to_user|| fm.le_report_to_user 
    query.cc_users = fm.cc_users|| fm.le_cc_users 
    query.create_time = fm.create_time|| fm.le_create_time 
    query.update_time = fm.update_time|| fm.le_update_time 
    query.wr_id = fm.wr_id

      //2023.4.18添加---

    query.$title="详情"
    this.$refs.cmpnt_aabbs.show(query)
  },
  //添加
  show_cmpnt_aabbv(fm = {}){
    let query = {} 
    query.start_date = fm.start_date|| fm.le_start_date 
    query.end_date = fm.end_date|| fm.le_end_date 
    query.report_content = fm.report_content|| fm.le_report_content 
    query.feedback_content = fm.feedback_content|| fm.le_feedback_content 
    query.report_to_user = fm.report_to_user|| fm.le_report_to_user 
    query.cc_users = fm.cc_users|| fm.le_cc_users 
    query.wr_id = fm.wr_id

      //2023.4.18添加---

    query.$title="添加"
    this.$refs.cmpnt_aabbv.show(query)
  },
  //修改
  show_cmpnt_aabbt(fm = {}){
    let query = {} 
    query.start_date = fm.start_date|| fm.le_start_date 
    query.end_date = fm.end_date|| fm.le_end_date 
    query.report_content = fm.report_content|| fm.le_report_content 
    query.feedback_content = fm.feedback_content|| fm.le_feedback_content 
    query.report_to_user = fm.report_to_user|| fm.le_report_to_user 
    query.cc_users = fm.cc_users|| fm.le_cc_users 
    query.wr_id = fm.wr_id

      //2023.4.18添加---

    query.$title="修改"
    this.$refs.cmpnt_aabbt.show(query)
  },
  //删除
  show_cmpnt_aabbu(fm = {}){
    let query = {} 
    query.wr_id = fm.wr_id|| fm.le_wr_id 
    query.wr_id = fm.wr_id

      //2023.4.18添加---

    query.$title="删除"
    this.$refs.cmpnt_aabbu.show_aabbu(query)
  },
},
};
</script>
<style>
.el-dialog{
  border-radius:5px !important
}
</style>
<style scoped>
.el-form-item {
  margin-right: 10px !important;
}

.opts .el-button--small {
  margin-left: 0px;
  padding-left: 0px;
  margin-right: 4px;
}

/deep/.el-table td.el-table__cell div {
  vertical-align: middle;
}
/deep/.el-button+.el-dropdown{
  margin-left:0px;
}
/deep/.el-button+.el-button{
  margin-left:0px;
}
.el-button{
  padding-left: 6px !important;
  padding-right: 6px !important;
}
.blist {
  margin-bottom: 8px;
  width: 100%;
}

.blist .el-radio-group {
  margin-right: 8px;
}

.ddl {
  margin-bottom: 8px;
  width: 100%;

}

.ddl .el-dropdown {
  margin-right: 8px;
}

.listbar {
  margin-bottom: 8px;
  text-align: center;
}
 .el-dropdown-link {
  cursor: pointer;
  color: var(--el-color-primary);
  display: flex;
  align-items: center;
  font-size: 0.65rem;
}
/deep/.el-button--small{
  padding: 5px 4px;
}

.prepend /deep/.el-input__wrapper{
  border-top-right-radius:0;
  border-bottom-right-radius:0;
}
.prepend+/deep/.el-date-editor{
  border-top-left-radius:0;
  border-bottom-left-radius:0;
  border-left:0;
}

</style>